package org.jgs1904.test;

import java.util.Scanner;

/**
 * @author: 默苍璃
 * @date: 2022-09-08 14:34
 * <p>
 * 控制台打印
 */
public class Print {
    public static void main(String[] args) {

        //换行输出
        System.out.println(1);
        System.out.println(2);
        System.out.println(3);

        //不换行输出
        System.out.print(1);
        System.out.print(2);
        System.out.print(3);
        System.out.println();

        //格式化输出
        double d1 = 12900000;
        // 1.29E7
        System.out.println(d1);

        double d = 3.1415926;
        // 显示两位小数3.14
        System.out.printf("%.2f\n", d);
        // 显示4位小数3.1416
        System.out.printf("%.4f\n", d);

        System.out.println("______________________________华丽的分割线_________________________________");

        //控制台输入
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入姓名:");
        String name = scanner.nextLine();
        System.out.println("输入年龄:");
        int age = scanner.nextInt();
        System.out.println("输入身高:");
        double height = scanner.nextDouble();

        //关闭资源
        scanner.close();

        //格式化输出
        System.out.printf("姓名:%s,年龄:%d,身高:%.2f", name, age, height);

    }

}
